package clientclass

//实现websocket客户端类

import (
	"encoding/json"
	"log"
	message "messageservice/message-class"

	"github.com/gorilla/websocket"
)

type WebSocket struct {
	Id    string
	Group map[string]string
	Conn  *websocket.Conn
}

func (ws *WebSocket) Send(Message message.Message) {
	buff, err := json.Marshal(Message)
	if err != nil {
		log.Println("JSON解析错误", err)
		return
	}

	err = ws.Conn.WriteMessage(websocket.TextMessage, buff)
	if err != nil {
		log.Println("发送发生错误", err)
		return
	}
}
